using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace OpenFlashChartLib
{
    public class Title:RenderBase
    {
        public static readonly string TitleToken = "title";
        private string _text = "Chart title";

        public string Text
        {
            get { return _text; }
            set { _text = value; }
        }

        public Style Style
        {
            get { return _titleStyle; }
            set { _titleStyle = value; }
        }

        private Style _titleStyle = new Style();

        public override void RenderContent(HtmlTextWriter writer)
        {
            writer.Write(TitleToken);
            writer.Write("=");
            writer.Write(Util.ToSafeString(_text));
            if (!_titleStyle.IsEmpty)
            {
                writer.Write(",{");
                RenderStyles(Style.GetStyleAttributes(null), writer);
                writer.Write("}");
            }
        }

        protected void RenderStyles(CssStyleCollection styles, HtmlTextWriter writer)
        {
            foreach (string key in styles.Keys)
            {
                writer.Write("{0}:{1};", key, styles[key]);
            }
        }
    }
}
